/**
 * Title: FeedbackActivity.java
 * Description:
 * Copyright: Copyright (c) 2008
 * Company:深圳彩讯科技有限公司
 * Author 罗旭东 (hi@luoxudong.com)
 * Date 2014-2-8 下午1:50:18
 * Version 1.0
 */
package com.luoxudong.phonenumber.ui.activities;

import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.luoxudong.phonenumber.R;
import com.luoxudong.phonenumber.ui.common.listener.OnClickAvoidForceListener;
import com.luoxudong.phonenumber.ui.utils.ToastUtil;
import com.luoxudong.phonenumber.ui.widgets.titlebar.ITitleBarOnClickListener;
import com.luoxudong.phonenumber.ui.widgets.titlebar.TitleBarView;

/** 
 * ClassName: FeedbackActivity
 * Description:TODO(这里用一句话描述这个类的作用)
 * Create by 罗旭东
 * Date 2014-2-8 下午1:50:18
 */
public class FeedbackActivity extends BaseActivity{
	public static final int MSG_SHOW_TIP = 1;
	private TitleBarView titleBarView = null;
	private EditText feedbackText = null;
	private Button sendBtn = null;
	
	
	@Override
	protected int getContentViewLayoutResId() {
		return R.layout.feedback_layout;
	}

	@Override
	protected void onCreateFindView(Bundle savedInstanceState) {
		titleBarView = (TitleBarView)findViewById(R.id.title_bar);
		feedbackText = (EditText)findViewById(R.id.tv_feedback);
		sendBtn = (Button)findViewById(R.id.btn_send);
		
		titleBarView.setTitle(R.string.feedback);
		titleBarView.changeMode(TitleBarView.MODEL_BACK);
		setHideProgressDialog(false);
	}

	@Override
	protected void onCreateAddListener(Bundle savedInstanceState) {
		titleBarView.setTitleBarOnClickListener(titleBarOnClickListener);
		sendBtn.setOnClickListener(onClickListener);
	}

	@Override
	protected void onCreateInitData(Bundle savedInstanceState) {
		
	}

	@Override
	protected void onCreateTaskLoadData() {
		
	}

	@Override
	protected void onCreateTaskAddView() {
		
	}

	@Override
	protected void refreshUI(Object obj) {
		
	}
	
	@Override
	protected void handleMessage(Message msg) {
		switch (msg.what) {
		case MSG_SHOW_TIP:
			ToastUtil.showToast(FeedbackActivity.this, (String)msg.obj);
			break;

		default:
			break;
		}
	}
	
	private void goback()
	{
		
	}
	
	private void sendFeedback()
	{
		String msg = feedbackText.getText().toString();
		feedbackText.setText("");
		
		if (msg == null || "".equals(msg.trim()))
		{
			sendMessage(obtainMessage(MSG_SHOW_TIP, "请填写您的宝贵意见建议"));
			return;
		}
		sendMessage(obtainMessage(MSG_SHOW_TIP, "您的宝贵意见已提交成功!"));
	}
	
	private OnClickAvoidForceListener onClickListener = new OnClickAvoidForceListener()
	{

		@Override
		public void onClickAvoidForce(View v) {
			switch (v.getId()) {
			case R.id.btn_send:
				sendFeedback();
				break;
			
			default:
				break;
			}
		}
		
	};
	
	private ITitleBarOnClickListener titleBarOnClickListener = new ITitleBarOnClickListener() {
		
		@Override
		public void onRightClick(View v) {
		}
		
		@Override
		public void onLeftClick(View v) {
			goback();
			finish();
		}
	};
}
